package com.example.beangenerate.config;

import com.example.beangenerate.dao.MybatisDao;
import com.example.beangenerate.dao.MybatisDaoImpl;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
@AutoConfigureAfter({MybatisAutoConfiguration.class})
public class HlinfoMybatisDaoAutoConfiguration {

	/**
	 * 配置MybatisDao，注入SqlSessionTemplate
	 * @param sqlSessionTemplate
	 * @return mybatisDao实例化对象
	 */
    @Bean
	@Primary
    public MybatisDao mybatisDao(SqlSessionTemplate sqlSessionTemplate){
    	MybatisDao mybatisDao = new MybatisDaoImpl(sqlSessionTemplate);
    	return mybatisDao;
    }
}
